/*================================================================
*   Copyright (C) 2017 LiuYao. All rights reserved.
*   
*   Filename : node.h
*   Author : LiuYao
*   Date : 2017-11-26
*   Description :  the abstract base Node class
*
================================================================*/
#ifndef _NODE_H
#define _NODE_H

#include <vector>
#include "../matrix/matrix.h"
#include "../session/context.h"

using std::vector;

class Context;

class Node {
    private:
        // input node list
        vector<Node*>* node_in_list_;
        // output node list
        vector<Node*>* node_out_list_;
        // the matrix shape of output
        Shape* out_shape_;
        // forbid copying
        Node(const Node & ) = default;
        Node(Node && ) = default;

    public:
        Node(const vector<Node*>& nodes);
        virtual ~Node();

        virtual void compute(Context* ) = 0;    

        virtual bool isVariable() const = 0;
        virtual bool isConstant() const = 0;
        virtual bool isOp() const = 0;
        virtual bool isPlaceholder() const = 0;
        virtual bool isOptimizer() const = 0;

        vector<Node*>* getNodeIn() const { return node_in_list_; }
        vector<Node*>* getNodeOut() const { return node_out_list_; }
        Shape* getOutShape() const { return out_shape_; }

        void addNodeIn(Node* node){ node_in_list_ -> emplace_back(node); }
        void addNodeOut(Node* node){ node_out_list_ -> emplace_back(node); }
        void setOutShape(const Shape* shape);
};

#endif

